/*
    This file is part of Emu.

    Emu is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Emu is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Emu.  If not, see <http://www.gnu.org/licenses/>. */
#ifndef ELISTPROPEDITOR_H
# define ELISTPROPEDITOR_H

# include <QPushButton>
# include <QTreeWidget>

# include "eprofile.h"
# include "eeditorwidget.h"

/* This is the property that the manager will be working with. */
enum EPropType {
    EPropAliases,
    EPropMacros,
    EPropTriggers
};

class EListPropEditor : public EEditorWidget
{
    Q_OBJECT

public:
    EListPropEditor(EProfile *, EPropType);

    void applyPrefChanges();

private:
    QTreeWidgetItem *createCheckChildItem(QString);
    QTreeWidgetItem *createChildItem(QString, QString);
    void baseDeleteItem();
    void baseMoveItem(int);
    void createItemForAlias(EAlias);
    void createItemForMacro(EMacro);
    void createItemForTrigger(ETrigger);
    void setDirectionsEnabled(int);
    void setEditingEnabled(bool);
    void updateDirectionsEnabled();
    void updateItemCount();
    void updateItemForAlias(QTreeWidgetItem *, EAlias);
    void updateItemForMacro(QTreeWidgetItem *, EMacro);
    void updateItemForTrigger(QTreeWidgetItem *, ETrigger);

    EPropType _propType;
    int _currentItemIndex;

    QTreeWidget *_managerTree;
    QPushButton *_addButton;
    QPushButton *_deleteButton;
    QPushButton *_downButton;
    QPushButton *_editButton;
    QPushButton *_upButton;

    EProfile *_profile;
    QList<EAlias> _aliases;
    QList<EMacro> _macros;
    QList<ETrigger> _triggers;

private slots:
    void addItem();
    void deleteItem();
    void editItem();
    void itemDown();
    void itemUp();
    void itemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
};

#endif
